package com.lc.hongtai.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lc.hongtai.MyApplication;
import com.lc.hongtai.R;
import com.lc.hongtai.activity.CredittransferDetailActivity;
import com.lc.hongtai.conn.JsonBond;
import com.lc.hongtai.view.ProgressBar;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 4/25/2016.
 */
public class CredittransferListAdapter extends RecyclerView.Adapter<CredittransferListAdapter.ViewHolder> {


    private Context context;
    private List<JsonBond.Info.ListContent> list;

    public CredittransferListAdapter(Context context, List<JsonBond.Info.ListContent> list) {
        this.context = context;
        this.list = list;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        // each data item is just a string in this case


        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.tv_sumMoney)
        TextView tvSumMoney;
        @Bind(R.id.tv_rate)
        TextView tv_rate;
        @Bind(R.id.transfer_price)
        TextView transfer_price;

        @Bind(R.id.progress_horizontal)
        ProgressBar progress_horizontal;


        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.list_18_item_view_beifen, null)));

        ViewHolder vh = new ViewHolder(view);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {
        holder.tvName.setText("项目名称" + list.get(position).borrow_name);
        holder.tvSumMoney.setText(list.get(position).transfer_price + "元");
        // holder.tv06.setText(list.get(position).money + "元");

        holder.tvName.setText(list.get(position).borrow_name);

        // holder.text_tranfour.setText(list.get(position).status);
        String string = list.get(position).status;
        holder.tv_rate.setText(list.get(position).borrow_interest_rate);
holder.transfer_price.setText(list.get(position).transfer_price);

//        holder.progress_horizontal.setProgress(list.get(position).);

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("id", list.get(position).id);
                intent.setClass(context, CredittransferDetailActivity.class);
                context.startActivity(intent);
            }
        });
    }


    @Override
    public int getItemCount() {
        return list.size();
    }


}

